package com.finchina.myview.LayoutAnimations;


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.finchina.myview.R;

/**
 * 
 * @ClassName: MainModuleAdapter 
 * @Description: TODO(主界面模块) 
 * @author (黄赛赛)
 * @date 2015-4-10 下午2:07:05 
 *
 */
public class MainModuleAnimationAdapter extends BaseAdapter{

	int[] imgs = { R.drawable.ic_module_enterise_info,
			R.drawable.ic_module_special_operation,
			R.drawable.ic_module_administrative_punish,
			R.drawable.ic_module_complaint_letters,
			R.drawable.ic_module_map,
			R.drawable.ic_module_emegency_disposal,
			R.drawable.ic_module_msg_hint,
			R.drawable.ic_module_daliy_supervision,
			R.drawable.ic_module_office_remind,
			R.drawable.ic_module_mail_notifaction,
			R.drawable.ic_module_enviroment_protection_materia,
			R.drawable.ic_module_field_instruments,
			};

	Context mContext;
	LayoutInflater layoutInflater = null;

	public MainModuleAnimationAdapter(Context mContext) {
		this.mContext = mContext;
		layoutInflater = LayoutInflater.from(mContext);

	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return 12;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return imgs[position];
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	class ViewHolder {
		ImageView iv_icon;

	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder holder = null;
		if (convertView == null) {
			holder = new ViewHolder();
			convertView = layoutInflater.inflate(
					R.layout.item_module, null);
			holder.iv_icon = (ImageView) convertView.findViewById(R.id.iv_icon);

			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}

		 holder.iv_icon.setBackgroundResource(imgs[position]);


		return convertView;
	}

	public void destory(){
		notifyDataSetChanged();
		mContext = null;
		layoutInflater = null;
		imgs = null;
	}

}
